<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>xeokit Example</title>
    <link href="../css/pageStyle.css" rel="stylesheet"/>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/js/all.min.js"></script>
</head>
<body>
<input type="checkbox" id="info-button"/>
<label for="info-button" class="info-button"><i class="far fa-3x fa-question-circle"></i></label>
<canvas id="myCanvas"></canvas>
<div class="slideout-sidebar">
    <h1>XKTLoaderPlugin</h1>
    <h2>Demonstrates "rounding jitter"</h2>
    <p>In this example, we're loading a double-precision BIM model, while effectively disabling xeokit's
        double-precision emulation. This results in rounding error while rendering, known as "rounding jitter".</p>
    <p>Rounding jitter can be eliminated by using xeokit's double-precision emulation.</p>
    <ul>
        <li>Model center is [1842022, 10, -5173301]</li>

    </ul>
    <h3>Components Used</h3>
    <ul>
        <li>
            <a href="../../docs/class/src/viewer/Viewer.js~Viewer.html"
               target="_other">Viewer</a>
        </li>
        <li>
            <a href="../../docs/class/src/plugins/XKTLoaderPlugin/XKTLoaderPlugin.js~XKTLoaderPlugin.html"
               target="_other">XKTLoaderPlugin</a>

        </li>
    </ul>
    <h3>Tutorials</h3>
    <ul>
        <li><a href="https://www.notion.so/xeokit/Viewing-Double-Precision-Models-3f9e155fd1394d1f974474484decf31b"
               target="_other">Viewing Double Precision Models</a></li>
    </ul>
    <h3>Assets</h3>
    <ul>
        <li>Model provided by <a href="https://bimdata.io" target="_other">BIMData.io</a></li>
    </ul>
</div>
</body>

<script type="module">

    //------------------------------------------------------------------------------------------------------------------
    // Import the modules we need for this example
    //------------------------------------------------------------------------------------------------------------------

    import {Viewer, XKTLoaderPlugin} from "../../dist/xeokit-sdk.min.es.js";

    //------------------------------------------------------------------------------------------------------------------
    // Create a Viewer, arrange the camera
    //------------------------------------------------------------------------------------------------------------------

    const viewer = new Viewer({
        canvasId: "myCanvas",
        transparent: true
    });

    viewer.camera.eye = [-3.933, 2.855, 27.018];
    viewer.camera.look = [4.400, 3.724, 8.899];
    viewer.camera.up = [-0.018, 0.999, 0.039];

    //----------------------------------------------------------------------------------------------------------------------
    // Create a xeokit loader plugin, load a model, fit to view
    //----------------------------------------------------------------------------------------------------------------------

    const xktLoader = new XKTLoaderPlugin(viewer);

    const model1 = xktLoader.load({
        id: "myModel1",
        src: "../../assets/models/xkt/v3/MAP/MAP.xkt",
        metaModelSrc: "../../assets/models/xkt/v3/MAP/MAP.json",
        edges: true,
        excludeTypes: ["IfcSpace"],
        objectDefaults: {}
    });

    model1.on("loaded", () => {
        viewer.cameraFlight.jumpTo(model1);
    });

    viewer.scene.on("tick", () => {
        viewer.scene.camera.orbitYaw(1.0);
    });

</script>
</html>
